package com.woniuxy01;

/**
 * @author 作者
 * @create 2025-07-18 10:36
 */
public class Test10 {
    public static void main(String[] args) {

        int[] a = {21, 12, 36, 54, 5, 16, 7, 28, 9};
        System.out.println("排序前");
        for (int i : a) {
            System.out.print(i + "\t");
        }
        System.out.println();
        //冒泡排序
        for (int i = 0; i < a.length - 1; i++) {
            //每轮比较多少次
            for (int j = 0; j < a.length - 1 - i; j++) {
                if (a[j] > a[j + 1]) {
                    //交换
                    int t = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = t;
                }
            }
        }

        System.out.println("排序后");
        for (int i : a) {
            System.out.print(i + "\t");
        }

    }
}
